package com.springbootstudy.demo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class MyMvcConfig extends WebMvcConfigurationSupport {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // super.addViewControllers(registry);
        //浏览器发送 /atguigu 请求来到 success
        registry.addViewController("/").setViewName("login");
    }


//    public LoginHandlerInterceptor userActionInterceptor(){
//        return new LoginHandlerInterceptor();
//    }
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        // 多个拦截器组成一个拦截器链
//        // addPathPatterns 用于添加拦截规则
//        // excludePathPatterns 用户排除拦截
//        String[] ex=new String[]{"/index.html","/","/user/login","/Query/**" };
//
//        registry
//                . addInterceptor(userActionInterceptor())
//
//                .addPathPatterns("/**")
//                .excludePathPatterns(ex);
//        super.addInterceptors(registry);
//    }
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//
//        //将所有/** 访问都映射到classpath:/public/ 目录下
//        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
//        registry.addResourceHandler("/public/**").addResourceLocations("classpath:/public/");
//        registry.addResourceHandler("/templates/**").addResourceLocations("classpath:/templates/");
//
//    }


}
